-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement TX v4 experimental #1201
base: main
Are you sure you want to change the base?
Conversation
"github.com/corazawaf/coraza/v3/types" | ||
) | ||
|
||
type Transaction interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this interface is meaningless, if someone wants to access this fields they can create their own convenience interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package test
import (
"context"
"testing"
"github.com/corazawaf/coraza/v3"
"github.com/corazawaf/coraza/v3/types"
)
type transaction interface {
types.Transaction
Context() context.Context
}
func TestCoraza(t *testing.T) {
waf, _ := coraza.NewWAF(coraza.NewWAFConfig())
tx, ok := waf.NewTransaction().(transaction)
if !ok {
t.Errorf("cannot access Token")
}
tx.Context().Value("key")
}
It is not possible to access internal fields using this hack
Context IS required to control timeout for certain actions, among others
@@ -1576,6 +1576,14 @@ func (tx *Transaction) String() string { | |||
return res.String() | |||
} | |||
|
|||
func (tx *Transaction) UnixTimestamp() int64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is controversial and that is why I'd like to use use cases before exposing this. Why not a time.Time? Not saying that is the answer, just saying we need concrete use cases.
Make sure that you've checked the boxes below before you submit PR:
Thanks for your contribution ❤️